<?php
if (isset($url['m']) && isnum($url['m']) && $url['m'] > 0) { $mid = $url['m']; }
else { $mid = 0; }
if ($mid == 0) { $error = "Tokio vartotojo nėra"; }
// Jei kitas vartotojas noi perziureti kita vartotoja
if (isset($mid) && (int)$mid) {
	$watch = "yes";
	$self = "no";
	$sql = mysql_fetch_assoc(mysql_query1("SELECT * FROM users WHERE id='" . $mid ."'"));
	if (!$sql) { $error = "Toks vartotojas nerastas"; }
	if (!isset($error)) {
		if (isset($_SESSION['username']) && $sql['nick'] == $_SESSION['username']) { $self = "yes"; }
		$sql2 = mysql_fetch_assoc(mysql_query1("SELECT * FROM salis WHERE iso='" . $sql['salis'] ."'"));
	}
}

// Jeigu vartotojas pats save nori perziureti
if (!isset($mid) AND $mid > 0) {
	$watch = "no";
	$self = "yes";
	if (isset($_SESSION['username'])) {
		$sql = mysql_fetch_assoc(mysql_query1("SELECT * FROM users WHERE nick=" . escape($_SESSION['username']) .""));
		$sql2 = mysql_fetch_assoc(mysql_query1("SELECT * FROM salis WHERE iso=" . escape($sql['salis']) .""));
	}
}

// Balsavim orezultatas apskaiciuoti
if (isset($_POST['action']) && $_POST['action'] == 'vote_user') {
	$balsai = explode(";",$_POST['balsas']);
	$balsas = $balsai['0'];
	$uzeris = $balsai['1'];
	if ((int)$balsas && (int)$uzeris) {
		$balsavo = mysql_fetch_assoc(mysql_query1("SELECT balsavo,balsai FROM users WHERE id='" . $uzeris ."'"));
		$a = 0;
		$total = count($balsavo);
		while ($a < $total) {
			$balsuotojai = $balsavo[$a] . ";";
			$a++;
		}
		$balsuotojai = $balstuojai . $_SESSION['username'] . ";";
		$balsai = ($sql3['balsai'] + $balsas) / (count($balsavo) + 1);
		mysql_query1("UPDATE users SET balsavo='" . $balsuotojai ."', balsai='" . $balsai ."' WHERE id='" . $uzeris ."'");
		unset($balsavo,$uzeris,$balsuotojai,$balsai,$balsavo,$a);
	}
}

// Jei suklydo vesdami vartotojo ID arba bando nulauzti
if (isset($error)) { klaida("Vartotojas nerastas",$error); }

// Jei nera klaidu...
if (!isset($error)) {
	// Jei kitas vartotojas perziuri kita vartotoja BET ne SAVE
	if ($self == "no") {
		$text = "
		<fieldset>
		<legend>Informacija</legend>
		<table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">
		<tr>
		<td height=\"116\" colspan=\"2\" align=\"center\" valign=\"middle\" width=\"30%\"><img src='images/avatars/no_image.jpg' alt='Nėra kaukės' /></td>
		<td colspan=\"6\" valign=\"top\">
			<fieldset>
				<table border=\"0\" width=\"100%\">
					<tr>
						<td colspan=\"2\" class=\"title\">Vartotojo informacija</td>
					</tr>
					<tr>
						<td>Vartotojas:</td>
						<td>" . $sql['nick'] ."</td>
					</tr>
					<tr>
						<td>Vardas:</td>
						<td>" . $sql['vardas'] ."</td>
					</tr>
					<tr>
						<td>Pavardė:</td>
						<td>" . $sql['pavarde'] ."</td>
					</tr>
					<tr>
						<td>Amžius:</td>
						<td>" . amzius($sql['gim_data']) ."</td>
					</tr>
					<tr>
						<td>Šalis:</td>
						<td>" . $sql2['printable_name'] ." <img src='images/icons/" . strtolower($sql['salis']) .".png'></img></td>
					</tr>
					<tr>
						<td>Miestas:</td>
						<td>" . $sql['miestas'] ."</td>
					</tr>
				</table>
			</fieldset>
		</td>
		</tr>
		<tr>
		<td colspan=\"8\" valign=\"top\">
		<fieldset>
			<table border=0 width=100%>
				<tr>
					<td class=\"title\">Parašas</td>
				</tr>
				<tr>
					<td>" . bbcode($sql['parasas']) ."</td>
				</tr>
			</table>
		</fieldset><br />
		</td>
		</tr>
		<tr>
		<td colspan=\"2\" rowspan=\"3\" valign=\"top\">
			<fieldset>
				<table border=0 width=100%>
					<tr>
						<td colspan=\"2\" class=\"title\">Forumo informacija</td>
					</tr>
					<tr>
						<td>Sukurta temų:</td>
						<td>" . $sql['forum_temos'] ."</td>
					</tr>
					<tr>
						<td>Parašyta pranešimų:</td>
						<td>" . $sql['forum_atsakyta'] ."</td>
					</tr>
				</table>
			</fieldset>
		</td>
		<td width=\"4\">&nbsp;</td>
		<td colspan=\"2\" rowspan=\"5\" valign=\"top\" width=\"40%\">
		<fieldset>
			<table border=0 width=100%>
				<tr>
					<td colspan=\"2\" class=\"title\">Bendra Informacija</td>
				</tr>
				<tr>
					<td>Prisiregistravęs:</td>
					<td>" . $sql['reg_data'] ."</td>
				</tr>
				<tr>
					<td>Paskutinis aktyvavimas:</td>
					<td>" . $sql['login_data'] ."</td>
				</tr>
				<tr>
					<td>Taškai:</td>
					<td>" . $sql['taskai'] ."</td>
				</tr>
				<tr>
					<td>Lygis:</td>
					<td>";
					if ($sql['levelis'] == 1) { $text .= "<img src='images/levelis/1.gif'></img>"; }
					if ($sql['levelis'] == 2) { $text .= "<img src='images/levelis/2.gif'></img>"; }
					if ($sql['levelis'] == 3) { $text .= "<img src='images/levelis/3.gif'></img>"; }
					if ($sql['levelis'] == 4) { $text .= "<img src='images/levelis/4.gif'></img>"; }
					if ($sql['levelis'] == 5) { $text .= "<img src='images/levelis/5.gif'></img>"; }
					if ($sql['levelis'] == 6) { $text .= "<img src='images/levelis/6.gif'></img>"; }
					if ($sql['levelis'] == 7) { $text .= "<img src='images/levelis/7.gif'></img>"; }
					if ($sql['levelis'] == 8) { $text .= "<img src='images/levelis/8.gif'></img>"; }
					if ($sql['levelis'] == 9) { $text .= "<img src='images/levelis/9.gif'></img>"; }
					if ($sql['levelis'] == 10) { $text .= "<img src='images/levelis/10.gif'></img>"; }
					if ($sql['levelis'] == 20) { $text .= "<img src='images/levelis/mod.gif'></img>"; }
					if ($sql['levelis'] == 30) { $text .= "<img src='images/levelis/admin.gif'></img>"; }
					$text .= "
					</td>
				</tr>
			</table>
		</fieldset>
		</td>
		<td>&nbsp;</td>
		<td colspan=\"2\" rowspan=\"9\" valign=\"top\">
		<fieldset>
			<table border=0 width=100%>
				<tr>
					<td colspan=\"2\" class=\"title\" width=\"30%\">Kontaktai</td>
				</tr>
				<tr>
					<td>ICQ:</td>
					<td>" . $sql['icq'] ."</td>
				</tr>
				<tr>
					<td>MSN:</td>
					<td>" . $sql['msn'] ."</td>
				</tr>
				<tr>
					<td>Skype:</td>
					<td>" . $sql['skype'] ."</td>
				</tr>
				<tr>
					<td>Yahoo:</td>
					<td>" . $sql['yahoo'] ."</td>
				</tr>
				<tr>
					<td>AIM:</td>
					<td>" . $sql['aim'] ."</td>
				</tr>
				<tr>
					<td>WWW:</td>
					<td>".linkas($sql['url'])."</td>
				</tr>
			</table>
		</fieldset>
		</td>
		</tr>
		<tr>
		<td>&nbsp;</td>
		<td width=\"4\">&nbsp;</td>
		</tr>
		<tr>
		<td>&nbsp;</td>
		<td>&nbsp;</td>
		</tr>
		<tr>
		<td colspan=\"2\" rowspan=\"5\" valign=\"top\">
		<fieldset>
			<table border=0 width=100%>
				<tr>
					<td colspan=\"2\" class=\"title\">Atsiuntimų informacija</td>
				</tr>
				<tr>
					<td>Straipsnių:</td>
					<td>" . $sql['atsiusta_straipsniu'] ."</td>
				</tr>
				<tr>
					<td>Pamokų:</td>
					<td>" . $sql['atsiusta_pamoku'] ."</td>
				</tr>
				<tr>
					<td>Skriptų:</td>
					<td>" . $sql['atsiusta_scriptu'] ."</td>
				</tr>
				<tr>
					<td>Naujienų:</td>
					<td>" . $sql['atsiusta_naujienu'] ."</td>
				</tr>
			</table>
		</fieldset>
		</td>
		<td>&nbsp;</td>
		<td>&nbsp;</td>
		</tr>
		<tr>
		<td>&nbsp;</td>
		<td>&nbsp;</td>
		</tr>
		<tr>
		<td>&nbsp;</td>
		<td colspan=\"2\" rowspan=\"2\" valign=\"top\">
		<fieldset>
			<table border=0 width=100%>
				<tr>
					<td colspan=\"2\" class=\"title\">Balsavimas</td>
				</tr>
				<tr>
					<td>";
					if ($sql['balsai'] >= 0) { $balai = "<img src=\"images/balsai/u0.gif\"></img> [" . $sql['balsai'] ."]"; }
					if ($sql['balsai'] >= 125) { $balai = "<img src=\"images/balsai/u1.gif\"></img> [" . $sql['balsai']."]"; }
					if ($sql['balsai'] >= 250) { $balai = "<img src=\"images/balsai/u2.gif\"></img> [" . $sql['balsai'] ."]"; }
					if ($sql['balsai'] >= 375) { $balai = "<img src=\"images/balsai/u3.gif\"></img> [" . $sql['balsai'] ."]"; }
					if ($sql['balsai'] >= 500) { $balai = "<img src=\"images/balsai/u4.gif\"></img> [" . $sql['balsai'] ."]"; }
					if ($sql['balsai'] >= 625) { $balai = "<img src=\"images/balsai/u5.gif\"></img> [" . $sql['balsai'] ."]"; }
					if ($sql['balsai'] >= 750) { $balai = "<img src=\"images/balsai/u6.gif\"></img> [" . $sql['balsai'] ."]"; }
					if ($sql['balsai'] >= 875) { $balai = "<img src=\"images/balsai/u7.gif\"></img> [" . $sql['balsai'] ."]"; }
					if ($sql['balsai'] >= 1000) { $balai = "<img src=\"images/balsai/u8.gif\"></img> [" . $sql['balsai'] ."]"; }
					$text .= $balai;
					$info2 = mysql_fetch_assoc(mysql_query1("SELECT balsavo FROM users WHERE id='" . $sql['id'] ."'"));
					if ($info2) {
						$balsavo = explode(";",$info2['balsavo']);
						$total = count($balsavo);
						$a = 0;
						while ($a < $total) {
							if (isset($_SESSION['username']) && $balsavo[$a] == $_SESSION['username']) { $nerror = "Balsavo"; }
							$a++;
						}
					}
					if (!isset($nerror)) {
						if (isset($_SESSION['username'])) {
							$text .= "
								<form name=\"vote\" action=\"\" method=\"post\">
								<select size=\"1\" name=\"balsas\">
										<option value=\"100;" . $sql['id'] ."\">1</option>
										<option value=\"200;" . $sql['id'] ."\">2</option>
										<option value=\"300;" . $sql['id'] ."\">3</option>
										<option value=\"400;" . $sql['id'] ."\">4</option>
										<option value=\"500;" . $sql['id'] ."\">5</option>
										<option value=\"600;" . $sql['id'] ."\">6</option>
										<option value=\"700;" . $sql['id'] ."\">7</option>
										<option value=\"800;" . $sql['id'] ."\">8</option>
										<option value=\"900;" . $sql['id'] ."\">9</option>
										<option value=\"1000;" . $sql['id'] ."\">10</option>
									</select>
									<input type=\"submit\" value=\"Balsuoti\">
									<input type=\"hidden\" name=\"action\" value=\"vote_user\" />
									</form>
								";
							}
						}
						unset($balsavo,$kukiai,$tota,$a,$nerror);
						$text .= "
					</td>
				</tr>
			</table>
		</fieldset>
		</td>
		<td>&nbsp;</td>
		</tr>
		<tr>
		<td>&nbsp;</td>
		<td>&nbsp;</td>
		</tr>
		<tr>
		<td>&nbsp;</td>
		<td width=\"122\">&nbsp;</td>
		<td width=\"118\">&nbsp;</td>
		<td>&nbsp;</td>
		</tr>
		<tr>
		<td width=\"34\">&nbsp;</td>
		<td width=\"200\">&nbsp;</td>
		<td>&nbsp;</td>
		";
		if ($self == "yes") { $text .= "<td align=\"center\"></td><td align=\"center\"></td>"; }
		if ($self == "no") {
			$text .= "
				<td align=\"center\">
				<form name=\"send_pm\" action='?id,45;n,1;u," . $sql['nick'] ."' method=\"post\">
				<input type=\"submit\" value=\"Siųsti privačia žinutę\">
				</form>
				</td>
				<td align=\"center\"><input type=\"submit\" value=\"Siųsti El. Laišką\"></td>
			"; 
		}
		$text .= "
		<td>&nbsp;</td>
		</tr>
		</table>
		</fieldset>
	";
	}
	
	// Jei vartotojas perziuri SAVE
	if ($self == "yes") {
	$text = "
		<fieldset>
		<legend>Informacija</legend>
		<table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">
		<tr>
		<td height=\"116\" colspan=\"2\" align=\"center\" valign=\"middle\" width=\"30%\"><img src='images/avatars/no_image.jpg' alt='Nėra kaukės' /></td>
		<td colspan=\"6\" valign=\"top\">
			<fieldset>
				<table border=\"0\" width=\"100%\">
					<tr>
						<td colspan=\"2\" class=\"title\">Vartotojo informacija</td>
					</tr>
					<tr>
						<td>Vartotojas:</td>
						<td>" . $sql['nick'] ."</td>
					</tr>
					<tr>
						<td>Vardas:</td>
						<td>" . $sql['vardas'] ."</td>
					</tr>
					<tr>
						<td>Pavardė:</td>
						<td>" . $sql['pavarde'] ."</td>
					</tr>
					<tr>
						<td>Amžius:</td>
						<td>" . amzius($sql['gim_data']) ."</td>
					</tr>
					<tr>
						<td>Šalis:</td>
						<td>" . $sql2['printable_name'] ." <img src='images/icons/" . strtolower($sql['salis']) .".png'></img></td>
					</tr>
					<tr>
						<td>Miestas:</td>
						<td>" . $sql['miestas'] ."</td>
					</tr>
				</table>
			</fieldset>
		</td>
		</tr>
		<tr>
		<td colspan=\"8\" valign=\"top\">
		<fieldset>
			<table border=0 width=100%>
				<tr>
					<td class=\"title\">Parašas</td>
				</tr>
				<tr>
					<td>" . bbcode($sql['parasas']) ."</td>
				</tr>
			</table>
		</fieldset><br />
		</td>
		</tr>
		<tr>
		<td colspan=\"2\" rowspan=\"3\" valign=\"top\">
			<fieldset>
				<table border=0 width=100%>
					<tr>
						<td colspan=\"2\" class=\"title\">Forumo informacija</td>
					</tr>
					<tr>
						<td>Sukurta temų:</td>
						<td>" . $sql['forum_temos'] ."</td>
					</tr>
					<tr>
						<td>Parašyta pranešimų:</td>
						<td>" . $sql['forum_atsakyta'] ."</td>
					</tr>
				</table>
			</fieldset>
		</td>
		<td width=\"4\">&nbsp;</td>
		<td colspan=\"2\" rowspan=\"5\" valign=\"top\" width=\"40%\">
		<fieldset>
			<table border=0 width=100%>
				<tr>
					<td colspan=\"2\" class=\"title\">Bendra Informacija</td>
				</tr>
				<tr>
					<td>Prisiregistravęs:</td>
					<td>" . $sql['reg_data'] ."</td>
				</tr>
				<tr>
					<td>Paskutinis aktyvavimas:</td>
					<td>" . $sql['login_data'] ."</td>
				</tr>
				<tr>
					<td>Taškai:</td>
					<td>" . $sql['taskai'] ."</td>
				</tr>
				<tr>
					<td>Lygis:</td>
					<td>";
					if ($sql['levelis'] == 1) { $text .= "<img src='images/levelis/1.gif'></img>"; }
					if ($sql['levelis'] == 2) { $text .= "<img src='images/levelis/2.gif'></img>"; }
					if ($sql['levelis'] == 3) { $text .= "<img src='images/levelis/3.gif'></img>"; }
					if ($sql['levelis'] == 4) { $text .= "<img src='images/levelis/4.gif'></img>"; }
					if ($sql['levelis'] == 5) { $text .= "<img src='images/levelis/5.gif'></img>"; }
					if ($sql['levelis'] == 6) { $text .= "<img src='images/levelis/6.gif'></img>"; }
					if ($sql['levelis'] == 7) { $text .= "<img src='images/levelis/7.gif'></img>"; }
					if ($sql['levelis'] == 8) { $text .= "<img src='images/levelis/8.gif'></img>"; }
					if ($sql['levelis'] == 9) { $text .= "<img src='images/levelis/9.gif'></img>"; }
					if ($sql['levelis'] == 10) { $text .= "<img src='images/levelis/10.gif'></img>"; }
					if ($sql['levelis'] == 20) { $text .= "<img src='images/levelis/mod.gif'></img>"; }
					if ($sql['levelis'] == 30) { $text .= "<img src='images/levelis/admin.gif'></img>"; }
					$text .= "
					</td>
				</tr>
			</table>
		</fieldset>
		</td>
		<td>&nbsp;</td>
		<td colspan=\"2\" rowspan=\"9\" valign=\"top\">
		<fieldset>
			<table border=0 width=100%>
				<tr>
					<td colspan=\"2\" class=\"title\" width=\"30%\">Kontaktai</td>
				</tr>
				<tr>
					<td>ICQ:</td>
					<td>" . $sql['icq'] ."</td>
				</tr>
				<tr>
					<td>MSN:</td>
					<td>" . $sql['msn'] ."</td>
				</tr>
				<tr>
					<td>Skype:</td>
					<td>" . $sql['skype'] ."</td>
				</tr>
				<tr>
					<td>Yahoo:</td>
					<td>" . $sql['yahoo'] ."</td>
				</tr>
				<tr>
					<td>AIM:</td>
					<td>" . $sql['aim'] ."</td>
				</tr>
				<tr>
					<td>WWW:</td>
					<td>".linkas($sql['url'])."</td>
				</tr>
			</table>
		</fieldset>
		</td>
		</tr>
		<tr>
		<td>&nbsp;</td>
		<td width=\"4\">&nbsp;</td>
		</tr>
		<tr>
		<td>&nbsp;</td>
		<td>&nbsp;</td>
		</tr>
		<tr>
		<td colspan=\"2\" rowspan=\"5\" valign=\"top\">
		<fieldset>
			<table border=0 width=100%>
				<tr>
					<td colspan=\"2\" class=\"title\">Atsiuntimų informacija</td>
				</tr>
				<tr>
					<td>Straipsnių:</td>
					<td>" . $sql['atsiusta_straipsniu'] ."</td>
				</tr>
				<tr>
					<td>Pamokų:</td>
					<td>" . $sql['atsiusta_pamoku'] ."</td>
				</tr>
				<tr>
					<td>Skriptų:</td>
					<td>" . $sql['atsiusta_scriptu'] ."</td>
				</tr>
				<tr>
					<td>Naujienų:</td>
					<td>" . $sql['atsiusta_naujienu'] ."</td>
				</tr>
			</table>
		</fieldset>
		</td>
		<td>&nbsp;</td>
		<td>&nbsp;</td>
		</tr>
		<tr>
		<td>&nbsp;</td>
		<td>&nbsp;</td>
		</tr>
		<tr>
		<td>&nbsp;</td>
		<td colspan=\"2\" rowspan=\"2\" valign=\"top\">
		<fieldset>
			<table border=0 width=100%>
				<tr>
				<td colspan=\"2\" class=\"title\">Balsavimas</td>
				</tr>
				<tr>
					<td>";
					if ($sql['balsai'] >= 0) { $balai = "<img src=\"images/balsai/u0.gif\"></img> [" . $sql['balsai'] ."]"; }
					if ($sql['balsai'] >= 125) { $balai = "<img src=\"images/balsai/u1.gif\"></img> [" . $sql['balsai']."]"; }
					if ($sql['balsai'] >= 250) { $balai = "<img src=\"images/balsai/u2.gif\"></img> [" . $sql['balsai'] ."]"; }
					if ($sql['balsai'] >= 375) { $balai = "<img src=\"images/balsai/u3.gif\"></img> [" . $sql['balsai'] ."]"; }
					if ($sql['balsai'] >= 500) { $balai = "<img src=\"images/balsai/u4.gif\"></img> [" . $sql['balsai'] ."]"; }
					if ($sql['balsai'] >= 625) { $balai = "<img src=\"images/balsai/u5.gif\"></img> [" . $sql['balsai'] ."]"; }
					if ($sql['balsai'] >= 750) { $balai = "<img src=\"images/balsai/u6.gif\"></img> [" . $sql['balsai'] ."]"; }
					if ($sql['balsai'] >= 875) { $balai = "<img src=\"images/balsai/u7.gif\"></img> [" . $sql['balsai'] ."]"; }
					if ($sql['balsai'] >= 1000) { $balai = "<img src=\"images/balsai/u8.gif\"></img> [" . $sql['balsai'] ."]"; }
					$text .= $balai . " Balsavo [" . count($sql['balsavo']) ."]
					</td>
				</tr>
			</table>
		</fieldset>
		</td>
		<td>&nbsp;</td>
		</tr>
		<tr>
		<td>&nbsp;</td>
		<td>&nbsp;</td>
		</tr>
		<tr>
		<td>&nbsp;</td>
		<td width=\"122\">&nbsp;</td>
		<td width=\"118\">&nbsp;</td>
		<td>&nbsp;</td>
		</tr>
		<tr>
		<td width=\"34\">&nbsp;</td>
		<td width=\"200\">&nbsp;</td>
		<td>&nbsp;</td>";
		if ($self == "yes") { $text .= "<td align=\"center\"></td><td align=\"center\"></td>"; }
		if ($self == "no") { $text .= "<td align=\"center\"><input type=\"submit\" value=\"Siųsti privačia žinutę\"></td><td align=\"center\"><input type=\"submit\" value=\"Siųsti El. Laišką\"></td>"; }
		$text .= "
		<td>&nbsp;</td>
		</tr>
		</table>
		</fieldset>
	";
	}
}


// Jeigu pereziurima TIK informacija, o vartotojas SAVES NEZIURI per nustatyta puslapi
if ($watch == "yes") {
	lentele("Vartotojo informacija",$text);
}
?>